package com.wy.controller;

import com.netsdk.apis.DeviceAPI;
import com.wy.service.wy.BuildingService;
import com.wy.service.wy.HouseholdService;
import com.wy.utils.BaseResponseInfo;
import com.wy.utils.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class TestController {

    private Logger log = LoggerFactory.getLogger(TestController.class);

    @Resource(name = "buildingServiceImpl")
    private BuildingService buildingService;


    @Resource(name = "householdServiceImpl")
    private HouseholdService householdService;

    @GetMapping("/testip")
	public BaseResponseInfo testip(HttpServletRequest request,
                                   String ip,String port,String username,String password,
                                   String channelId) {
        BaseResponseInfo info = new BaseResponseInfo();
        DeviceAPI deviceAPI = new DeviceAPI();
        boolean flag = deviceAPI.openDoor(ip,port,username,password,new Short(channelId));
        info.data = flag;
        return info;
	}

	@GetMapping("/clearImg")
    public BaseResponseInfo clearImg(){
        BaseResponseInfo info = new BaseResponseInfo();
//        FileUtil.conversionPath("d:\\test\\img","d:\\test\\img1","jpg");
        householdService.moveHousePic("d:\\test\\img1","d:\\test\\img2");
//        householdService.updatePicName("d:\\test\\img1","d:\\test\\img3");


//        FileUtil.conversionPath("/home/test/img","/home/test/img1","jpg");
//        householdService.moveHousePic("/home/test/img1","/home/test/img2");
//        householdService.updatePicName("/home/test/img1","/home/test/img3");


        return info;
    }


}

